using System;
using ValidationFramework.Reflection;

namespace ValidationFramework.Tests.TestHelpers
{
	/// <summary>
	/// A performance neutral implementation of IMemeberDescriptor 
	/// </summary>
	public class FakeReflectionInfo : ICachedReflectionInfo
	{
		// --- Fields
		private readonly RuntimeTypeHandle _memberTypeHandle;
		private readonly string _Name;
		private readonly object _returnValue;

		// --- Constructors
		public FakeReflectionInfo()
			: this(TypePointers.IntTypeHandle, "FakeProperty", 0)
		{
		}

		public FakeReflectionInfo(RuntimeTypeHandle memberTypeHandle)
			: this(memberTypeHandle, "FakeProperty", null)
		{
		}
		/// <summary>
		/// Initializes a new instance of the fakeMemberDescriptor class.
		/// </summary>
		public FakeReflectionInfo(RuntimeTypeHandle memberTypeHandle, string name, object getValueReturnValue)
		{
			_memberTypeHandle = memberTypeHandle;
			_Name = name;
			_returnValue = getValueReturnValue;
		}


		// --- IMemberDescriptor Members

		public RuntimeTypeHandle MemberTypeHandle
		{
			get { return _memberTypeHandle; }
		}

		public string Name
		{
			get { return _Name; }
		}

		public object GetValue(object instance)
		{
			return _returnValue;
		}
	}
}
